package com.huang.progressarcdemo;

import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {

    private Handler handler;
    private ProgressArc pb;
    private int progress;
    private ImageView imageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        pb = (ProgressArc) findViewById(R.id.pb);
        imageView = (ImageView) findViewById(R.id.iv);
        if (pb != null)
            pb.setMax(100);

        handler = new Handler();


    }

    public void click(View view) {
        imageView.setVisibility(View.INVISIBLE);
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (progress < 100) {
                    progress += 1;
                    pb.setmCurrentProgress(progress);
                    handler.postDelayed(this, 100);
                }else {
                    handler.removeCallbacks(this);
                }
            }
        }, 100);
    }
}
